<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
    <div class="container-div">
		<div class="btn-group hidden-xs" id="toolbar" role="group">
			<a class="btn btn-outline btn-success btn-rounded" onclick="$.operate.add()" shiro:hasPermission="dailymenu:manager:add">
				<i class="fa fa-plus"></i> 新增
			</a>
			<!-- <a class="btn btn-outline btn-danger btn-rounded" onclick="$.operate.removeAll()" shiro:hasPermission="dailymenu:manager:remove">
				<i class="fa fa-trash-o"></i> 删除
			</a> -->
		</div>
			
		<div class="col-sm-12 select-table table-striped">
			<table id="bootstrap-table" data-mobile-responsive="true"></table>
		</div>
    </div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('dailymenu:manager:edit')}]];
        var removeFlag = [[${@permission.hasPermi('dailymenu:manager:remove')}]];
        var types = [[${@dict.getType('menu_manager_type')}]];
        var datas = [[${@dict.getType('sys_normal_disable')}]];
        var open = [[${@dict.getType('daily_is_open')}]];
        var prefix = ctx + "dailymenu/menumanager"

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                modalName: "菜单",
                sortName: "menuSort",
                search: true,
		        showExport: false,
                columns: [
				{
					field : 'menuSort', 
					title : '显示顺序' 
				},
				{
					field : 'menuName', 
					title : '菜单名称' 
				},
				{
		            field: 'isBreakFast',
		            title: '早餐菜品',
		            formatter: function(value, row, index) {
		            	//alert((value == '0'||value == '1'));
		            	//alert(1==1);
		            	//alert(value);
			            return '<a href="#" onclick="detail(\'' + row.menuId + '\',0)">' + getDishNames(value) + '</a>';
			        }
		        },
				{
					field : 'isLunch', 
					title : '午餐菜品',
					formatter: function(value, row, index) {
			            return '<a href="#" onclick="detail(\'' + row.menuId + '\',1)">' + getDishNames(value) + '</a>';
			        }
				},
				{
					field : 'isDinner', 
					title : '晚餐菜品',
					formatter: function(value, row, index) {
			            return '<a href="#" onclick="detail(\'' + row.menuId + '\',2)">' + getDishNames(value) + '</a>';
			        }
				},
				{
					field : 'isOther',
					title : '其他餐菜品',
					formatter: function(value, row, index) {
			            return '<a href="#" onclick="detail(\'' + row.menuId + '\',3)">' + getDishNames(value) + '</a>';
			        }
				},
				{
		            field: 'menuType',
		            title: '菜单类型',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	return $.table.selectDictLabel(types, value);
		            }
		        },
		        {
		            field: 'status',
		            title: '状态',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	return $.table.selectDictLabel(datas, value);
		            }
		        },
		        {
					field : 'remark', 
					title : '备注' 
				},
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
		            	actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.menuId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.menuId + '\')"><i class="fa fa-remove"></i>删除</a>');
						return actions.join('');
		            }
		        }]
            };
            $.table.init(options);
        });
        
        function getDishNames(value){
        	if(value == '0' || value == '1'){
        		return $.table.selectDictLabel(open, value);
        	}else{
        		return value;
        	}
        }
        
        /*菜品-详细*/
		function detail(menuId,dinnerType) {
		    /* var url = prefix + '/detail/' + dictId;
		    createMenuItem(url, "字典数据"); */
		    
		    //alert(menuId+'-'+dinnerType);
		    
		    //var url = prefix + "/add";
			var url = prefix + '/dish/' + menuId+'/'+dinnerType;
			$.modal.open("选择菜品", url);
		} 
    </script>
</body>
</html>